package com.ys.controller;

import com.ys.common.R;
import com.ys.pojo.TradeGoods;
import com.ys.pojo.TradeGoodsNumberLog;
import com.ys.service.GoodsService;
import com.ys.pojo.TradeOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @RequestMapping("/findGoodsById")
    public R findGoodsById(@RequestBody TradeOrder order){
        TradeGoods goods = goodsService.findGoodsById(order);
        return R.ok().data("goods",goods);
    }


    @RequestMapping("/reduceGoodsNum")
    public R reduceGoodsNum(@RequestBody TradeGoodsNumberLog goodsNumberLog){
        Boolean aBoolean = goodsService.reduceGoodsNum(goodsNumberLog);
        return R.ok().success(aBoolean);
    }
}
